<%--
  Created by IntelliJ IDEA.
  User: jerry
  Date: 15/1/28
  Time: 上午1:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>执行总监登陆</title>

    <jsp:include page="/pages/include/includeCSS.jsp"></jsp:include>
  <script src="${pageContext.request.contextPath}/pages/assets/js/jquery-1.11.1.min.js"></script>
</head>
<body class="page-body login-page login-light">


<div class="login-container">

  <div class="row">

    <div class="col-sm-6">

      <script type="text/javascript">
        jQuery(document).ready(function($)
        {
          // Reveal Login form
          setTimeout(function(){ $(".fade-in-effect").addClass('in'); }, 1);


          // Validation and Ajax action
          $("form#login").validate({
            rules: {
              username: {
                required: true
              },

              password: {
                required: true
              }
            },

            messages: {
              username: {
                required: '用户名不能为空.'
              },

              password: {
                required: '请正确填写密码不能包含特殊字符.'
              }
            },

            // Form Processing via AJAX
            submitHandler: function(form)
            {
              show_loading_bar(70); // Fill progress bar to 70% (just a given value)

              var opts = {
                "closeButton": true,
                "debug": false,
                "positionClass": "toast-top-full-width",
                "onclick": null,
                "showDuration": "300",
                "hideDuration": "1000",
                "timeOut": "5000",
                "extendedTimeOut": "1000",
                "showEasing": "swing",
                "hideEasing": "linear",
                "showMethod": "fadeIn",
                "hideMethod": "fadeOut"
              };

              $.ajax({
                url: "${pageContext.request.contextPath}/app/manager/login",
                method: 'POST',
                dataType: 'json',
                data: {

                  username: $(form).find('#username').val(),
                  password: $(form).find('#password').val()
                },
                success: function(resp)
                {

                  show_loading_bar({
                    delay: .5,
                    pct: 100,
                    finish: function(){

                      // Redirect after successful login page (when progress bar reaches 100%)
                      if(resp.success)
                      {
                        window.location.href = '${pageContext.request.contextPath}/app/manager/manager';
                      }
                    }
                  });


                  // Remove any alert
                  $(".errors-container .alert").slideUp('fast');


                  // Show errors
                  if(resp.error)
                  {
                    $(".errors-container").html('<div class="alert alert-danger">\
												<button type="button" class="close" data-dismiss="alert">\
													<span aria-hidden="true">&times;</span>\
													<span class="sr-only">Close</span>\
												</button>\
												' + resp.errors + '\
											</div>');


                    $(".errors-container .alert").hide().slideDown();
                    $(form).find('#password').select();
                  }
                }
              });

            }
          });

          // Set Form focus
          $("form#login .form-group:has(.form-control):first .form-control").focus();
        });
      </script>

      <!-- Errors container -->
      <div class="errors-container">


      </div>

      <!-- Add class "fade-in-effect" for login form effect -->
      <form method="post" role="form" id="login" class="login-form fade-in-effect" action="${pageContext.request.contextPath}/app/manager/admin_login">

        <div class="login-header">
          <a href="index.jsp" class="logo">
              航天道1号执行总监登陆窗
              <span> 账号：admin 密码任意</span>

          </a>

          <p>执行总监登陆窗!</p>
        </div>


        <div class="form-group">
          <label class="control-label" for="username">账号</label>
          <input type="text" class="form-control" name="username" id="username" autocomplete="off" />
        </div>

        <div class="form-group">
          <label class="control-label" for="password">密码</label>
          <input type="password" class="form-control" name="password" id="password" autocomplete="off" />
        </div>

        <div class="form-group">
          <button type="submit" class="btn btn-primary  btn-block text-left">
            <i class="fa-lock"></i>
            提交
          </button>
        </div>

        <div class="login-footer">
          <a href="#">找回密码?</a>

          <div class="info-links">
            <a href="${pageContext.request.contextPath}">首页</a> -
            <a href="#">注册账户</a>
          </div>

        </div>

      </form>



    </div>

  </div>

</div>


<jsp:include page="../include/includeJavaScript.jsp" ></jsp:include>
</body>
</html>
